package pl.bizuteria.sklep.admin.client.ui.simple;

import pl.bizuteria.sklep.admin.client.place.ProxyListPlace;
import pl.bizuteria.sklep.api.shared.proxy.EaringProxy;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;

public class TopBarView extends Composite {

	private static TopBarViewUiBinder uiBinder = GWT
			.create(TopBarViewUiBinder.class);

	interface TopBarViewUiBinder extends UiBinder<Widget, TopBarView> {
	}

	@Inject
	public TopBarView(PlaceController placeController) {
		this.placeController = placeController;
		this.mojeResources = GWT.create(MyResources.class);
		this.mojeResources.css().ensureInjected();
		image = new Image(this.mojeResources.logo());
		image2 = new Image(this.mojeResources.logo2());
		initWidget(uiBinder.createAndBindUi(this));
	}

	@UiField(provided = true)
	MyResources mojeResources;

	@UiField
	Button button;

	@UiField
	Button button2;

	@UiField
	Button button3;

	@UiField(provided = true)
	Image image;

	@UiField(provided = true)
	Image image2;

	private final PlaceController placeController;

	@UiHandler("button")
	void onClick(ClickEvent e) {
		placeController.goTo(new ProxyListPlace(EaringProxy.class));
	}

	@UiHandler("button2")
	void onClick2(ClickEvent e) {
		Window.alert(mojeResources.logo().getSafeUri().asString());
	}
}
